package com.sky.service.impl;

import com.sky.constant.StatusConstant;
import com.sky.mapper.DishMapper;
import com.sky.mapper.SetmealMapper;
import com.sky.service.BusinessService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BusinessServiceImpl implements BusinessService {


    @Override
    //todo
    public BusinessDataVO businessData() {
        BusinessDataVO result = new BusinessDataVO();
        result.setNewUsers(10);
        result.setTurnover(Double.parseDouble("79798"));
        result.setUnitPrice(Double.parseDouble("18"));
        result.setValidOrderCount(69689);
        result.setOrderCompletionRate(Double.parseDouble("23"));


        return result;
    }

    @Autowired
    private SetmealMapper setmealMapper;
    @Override
    public SetmealOverViewVO overviewSetmeals() {
        int statusEnableCount = setmealMapper.selectStatusCount(StatusConstant.ENABLE);
        int statusDisableCount = setmealMapper.selectStatusCount(StatusConstant.DISABLE);
        return new SetmealOverViewVO(statusEnableCount, statusDisableCount);
    }

    @Autowired
    private DishMapper dishmapper;
    @Override
    public DishOverViewVO overviewDishes() {
        Integer statusEnableCount = dishmapper.countStatus(StatusConstant.ENABLE);
        Integer statusDisableCount = dishmapper.countStatus(StatusConstant.DISABLE);
        return new DishOverViewVO(statusEnableCount, statusDisableCount);
    }

    @Override
    //todo
    public OrderOverViewVO overviewOrders() {
        OrderOverViewVO result = new OrderOverViewVO();
        result.setAllOrders(12321);
        result.setCompletedOrders(9878);
        result.setCancelledOrders(198);
        result.setWaitingOrders(2311);
        result.setDeliveredOrders(111);
        return result;
    }
}
